import axios from "axios";
import {Notification} from  '@arco-design/web-vue'

const getHeaders= ()=>{
    return {
        'Authorization': window.sessionStorage.getItem('token'),
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    } ;
}


export  const LoginAjax= (data)=> axios.post('/api/manager/access/open/accountLogin' ,data)


//新增餐厨垃圾单

export  const AddWeighingAjax= async (data ={})=>{
  const response  =   await  axios.post('/api/manager/defense/support/addKitchen' ,data,  {headers:  getHeaders()})

    if (response.status!==200)  {
        Notification.error({ title:'操作失败' , content:'网络请求异常 请稍后再试'})
        return
    }
    if (response.data.code !==0 ) {
        Notification.error({ title:'操作失败' , content:response.data.message})
        return
    }
    if (response.data.code ===0 ) {
        Notification.success({ title:'操作成功' , content:response.data.message})
        return
    }
    return  response

}


// 新增称重计量单
export  const AddChefAjax= async (data ={})=>{
    const response  =   await  axios.post('/api/manager/defense/support/addMeasurement' ,data,  {headers:  getHeaders()})

    if (response.status!==200)  {
        Notification.error({ title:'操作失败' , content:'网络请求异常 请稍后再试'})
        return
    }
    if (response.data.code !==0 ) {
        Notification.error({ title:'操作失败' , content:response.data.message})
        return
    }
    if (response.data.code ===0 ) {
        Notification.success({ title:'操作成功' , content:response.data.message})
        return
    }
    return  response

}


